package org.test.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.test.dao.BookMapper;
import org.test.service.BookService;
import org.test.vo.Book;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class BookServiceImpl implements BookService {
    //注入DAO层
    @Autowired
    BookMapper bookMapper;

    @Override
    public Book addBook(Book book) {
        bookMapper.addABook(book);
        return book;
    }

    @Override
    public List<Book> getAllBooks(){
        List<Book> list = bookMapper.getAllBooks();
        return list;
    }

    @Override
    public Book getBookByBookid(int bookid) {
        return bookMapper.getBookByBookid(bookid);
    }

    @Override
    public List<Book> searchLikeBookname(String bookname) {
        return bookMapper.searchLikeBookname(bookname);
    }
}
